package com.duapk.search.util;

import java.io.File;

/**
 * IO操作工具类
 * 
 * @Package: com.duapk.search.util
 * @ClassName: IOUtils
 * @author: jiangzheng
 * @date: Apr 4, 2011 9:00:38 PM
 * 
 */
public class IOUtils {

	/**
	 * 删除指定目录
	 * 
	 * @Title: deleteFolder
	 * @author: jiangzheng
	 * @date: Apr 4, 2011 9:01:17 PM
	 * @param dir
	 *            目录全路径
	 * @return
	 */
	public static void deleteFolder(String dir) {
		deleteFolder(new File(dir));
	}

	/**
	 * 删除指定的目录
	 * 
	 * @param dir
	 *            目录对象
	 */
	public static void deleteFolder(File dir) {
		if (dir == null || !dir.exists()) {
			return;
		}
		File filelist[] = dir.listFiles();
		int listlen = filelist.length;
		for (int i = 0; i < listlen; i++) {
			if (filelist[i].isDirectory()) {
				deleteFolder(filelist[i]);
			} else {
				filelist[i].delete();
			}
		}
		dir.delete();
	}

}
